package com.splic.common.enums;

import com.splic.common.utils.StringUtils;

/**
 * ==========================
 * 开发：singe
 * 创建时间：2022-03-15 23:19
 * 版本: 1.0
 * 描述：商品周期对应天数
 * ==========================
 */
public enum GoodsCycleEnum {

    day("day",1),
    week("week",7),
    month("month",30),
    quarter("quarter",90),
    harf_year("harf_year",183),
    year("year",365),
    year2("two_years",730),
    year3("three_years",1095),
    ;

   private String code;
   private int num;

    GoodsCycleEnum(String code, int num) {
        this.code = code;
        this.num = num;
    }

    public String getCode() {
        return code;
    }

    public int getNum() {
        return num;
    }

    public static Integer getByCode(String code){
        if(StringUtils.isEmpty(code)){
            return null;
        }
        for(GoodsCycleEnum cycleEnum:GoodsCycleEnum.values()){
            if(StringUtils.equals(cycleEnum.code,code)){
               return cycleEnum.getNum();
            }
        }
        return null;
    }
}
